#!/usr/bin/env bash

# Slurm: use scontrol to reboot nodes
# Homepage: https://github.com/OleHolmNielsen/Slurm_tools/

NODES="$1"
ACTION=resume

if test $# -ne 1
then
	echo Usage: $0 nodename-list
	exit 1
fi

# Check the node list
if [[ "`sinfo -hN -n $NODES`" = "" ]]
then
	echo ERROR: Nodelist $NODES does not exist
	exit 1
fi

echo Reboot nodes $NODES with nextstate=$ACTION 
scontrol reboot asap nextstate=$ACTION $NODES 
sinfo -N -n $NODES
